/**
 * Created by y.chen on 2016/9/8.
 */
$(document).ready(function(){

    // var url = '/index.php/admin/Store/cityLink';
    // $.get(url,function(data){
    //     if(data.code == '0'){
    //         $.each(data.data, function (n, value) {
    //             $("#dslr-province").append("<option name="+value.region_name+" region_id="+value.region_id+" value="+value.region_id+">"+value.region_name+"</option>");
    //         });
    //     } else {
    //         alert(data.msg);
    //     }
    // },"json");
});

$('#dslr-province').change(function(){
    var region_id = $("#dslr-province  option:selected").attr("region_id");
    var url = '/index.php/admin/Store/cityLink/'+region_id;
    $.get(url,function(data){
        if(data.code == '0'){
            $("#dslr-region").html("<option value='-1'>==全部区域==</option>");
            $("#dslr-city").html("<option value='-1'>==全部城市==</option>");
            $("#store_id").html("<option value='-1'>==全部门店==</option>");


            $.each(data.data, function (n, value) {
                $("#dslr-city").append("<option name="+value.region_name+" region_id="+value.region_id+" value="+value.region_id+">"+value.region_name+"</option>");
            });

        } else {
            alert(data.msg);
        }
    },"json");

});

$('#dslr-city').change(function(){
    var region_id = $("#dslr-city  option:selected").attr("region_id");
    var url = '/index.php/admin/Store/cityLink/'+region_id;
    $.get(url,function(data){
        if(data.code == '0'){
            $("#dslr-region").html("<option value='-1'>==全部区域==</option>");
            $("#store_id").html("<option value='-1'>==全部门店==</option>");
            $.each(data.data, function (n, value) {
                $("#dslr-region").append("<option name="+value.region_name+" region_id="+value.region_id+" value="+value.region_id+">"+value.region_name+"</option>");
            });
        } else {
            alert(data.msg);
        }
    },"json");

});
